package com.opengate.base.utils;

import org.springframework.web.util.ContentCachingResponseWrapper;

import javax.servlet.http.HttpServletResponse;

/**
 * @author 曳戈泰尔
 * @version 1.0
 * @description 获取响应参数
 * @date 2023/4/26 5:46 PM
 */
public class ResponseUntil {

    /**
     * 获取响应参数
     *
     * @param response 响应
     * @return 响应参数
     */
    public static String getResponseParameter(HttpServletResponse response) {
        if (response instanceof ContentCachingResponseWrapper) {
            byte[] content = ((ContentCachingResponseWrapper) response).getContentAsByteArray();
            return new String(content);
        }

        return null;
    }
}
